using Headspring.Training.Domain.Model;
using StructureMap;

namespace Headspring.Training.Domain.Services
{
	[Pluggable(Keys.DEFAULT)]
    public class SmsSender: ISmsSender
    {
        private readonly IWirelessSender _wirelesssender;

        public SmsSender(IWirelessSender wirelesssender)
        {
            _wirelesssender = wirelesssender;
        }

        public void Send(WorkOrderNotification notification)
        {
            SmsMessage message = new SmsMessage();
            message.WirelessNumber = notification.Recipient.MobileNumber;
            message.MessageContents = notification.WorkOrder.Number + " changed from "
                          + notification.PreviousStatus + " to " + notification.WorkOrder.Status;
            if (notification.PreviousStatus == WorkOrderStatus.Complete && notification.WorkOrder.Status == WorkOrderStatus.Assigned)
            {
                message.MessageContents += ". Check your work better next time!";
            }
            _wirelesssender.Send(message);
        }
    }
}